package com.Day11;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author: 若若叶
 * @date: 2021/7/19 15:15
 * FileName: MyFileOutputStream
 * Description: 字节输入流
 */
public class MyFileOutputStream {
    public static void main(String[] args) {
        FileOutputStream fileOutputStream = null;
        try {
            //添加文件
            fileOutputStream = new FileOutputStream("E:\\JavaStudy\\DailyStudy\\src\\com\\Day11\\outfile",true);
            //新建数组，装着字符
            byte[] bytes = {100,105,103,99};
            //写入
            fileOutputStream.write(bytes);
            //写入最后要刷新
            fileOutputStream.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileOutputStream!=null){
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
